<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<script type="text/javascript" src="../jquery/jquery-1.8.2.js"></script>
<script type="text/javascript">
	function toAdd(){
		$.ajax({
		url:'<%=request.getContextPath()%>/equipment/equipment!toAdd.action',
		type:'post',
		data:{},
		success:function(){
			window.location.href='<%=request.getContextPath()%>/jsp/equipment_add.jsp';
		}
		});
	}
	
	
	function toUpdate(id){
		$.ajax({
		url:'<%=request.getContextPath()%>/equipment/equipment!toUpdate.action',
		type:'post',
		data:{"equipment.id":id},
		success:function(){
			window.location.href='<%=request.getContextPath()%>/jsp/equipment_update.jsp';
		}
		});
	}
	
	
	function toDelete(id){
		$.ajax({
		url:'<%=request.getContextPath()%>/equipment/equipment!deleteEquipment.action',
		type:'post',
		data:{"equipment.id":id},
		success:function(){
			window.location.href='<%=request.getContextPath()%>/equipment/equipment!findEquipmentList.action';
		}
		});
	}
</script>
  	<!-- 中 1/3 -->
   	<table border="1">
   		<tr>
   			<td>IP  地址</td>
   			<td>设备名称</td>
   			<td>设备型号</td>
   			<td>备   注</td>
   			<td>购买日期</td>
   			<td>设备类型</td>
   			<td>生产厂家</td>
   			<td>设备状态</td>
   			<td>操作 
	   			<button onclick="toAdd()">添加</button>
	   			<%--
	   			<a href="<%=request.getContextPath()%>/equipment/equipment!toAdd.action">添加</a>
	   			--%>
   			</td>
   		</tr>
   		<c:forEach items="${equipmentList }" var="equipment">
   			<tr>
   			
	   			<td>${equipment.ip }</td>
	   			<td>${equipment.name }</td>
	   			<td>${equipment.version }</td>
	   			<td>${equipment.note }</td>
	   			<td>${equipment.buydate }</td>
	   			<td>${equipment.type.typeName }</td>
	   			<td>${equipment.factory.factoryName }</td>
	   			<td>${equipment.status.statusName }</td>
	   			<td> 
		   			<button onclick="toUpdate(${equipment.id})">修改</button>
		   			<button onclick="toDelete(${equipment.id})">删除</button>	
		   			<%--
		   			<a href="<%=request.getContextPath()%>/equipment/equipment!toUpdate.action?equipment.id=${equipment.id}">修改</a>
		   			<a href="<%=request.getContextPath()%>/equipment/equipment!deleteEquipment.action?equipment.id=${equipment.id}">删除</a>
		   			--%>
	   			</td>
	   		
	   		</tr>
   		</c:forEach>
   	</table>
 
   		<!-- 下 1/3 -->
   		<jsp:include page="/common/ajaxpage.jsp"></jsp:include>
   